{template '_header'}
<div class="page-heading">
    <span class='pull-right'>
        {ifp 'groups.category.add'}
        <a class="btn btn-primary btn-sm" href="{php echo webUrl('groups/category/add')}">添加新商品分类</a>
        {/if}
    </span>
    <h2>商品分类</h2>
</div>
{if count($list)>0}
<form action="" method="post">
    <table class="table table-hover table-responsive">
        <thead class="navbar-inner">
            <tr>
                <th style="width:50px;">ID</th>
                <th style='width:80px'>显示顺序</th>
                <th>标题</th>
                <th>状态</th>
                <th >操作</th>
            </tr>
        </thead>
        <tbody id="sort">
            {loop $list $row}
            <tr>
                <td>{$row['id']}</td>
                <td>
                    {ifp 'groups.category.edit'}
                    <a href='javascript:;' data-toggle='ajaxEdit' data-href="{php echo webUrl('groups/category/displayorder',array('id'=>$row['id']))}" >{$row['displayorder']}</a>
                    {else}
                    {$row['displayorder']}
                    {/if}
                </td>
                <td><img src="{php echo tomedia($row['thumb'])}" onerror="this.src='../addons/ewei_shopv2/static/images/nopic100.jpg'" style="width:30px;height:30px;padding:1px;border:1px solid #ccc" /> {$row['name']}</td>
                <td>
                    <span class='label {if $row['enabled']==1}label-success{else}label-default{/if}'
                          {ifp 'groups.category.edit'}
                          data-toggle='ajaxSwitch'
                          data-switch-value='{$row['enabled']}'
                          data-switch-value0='0|隐藏|label label-default|{php echo webUrl('groups/category/enabled',array('enabled'=>1,'id'=>$row['id']))}'
                          data-switch-value1='1|显示|label label-success|{php echo webUrl('groups/category/enabled',array('enabled'=>0,'id'=>$row['id']))}'
                          {/if}
                          >
                          {if $row['enabled']==1}显示{else}隐藏{/if}</span>
                    </td>
                    <td style="text-align:left;">
                        {ifp 'groups.category.view|groups.category.edit'}
                        <a href="{php echo webUrl('groups/category/edit', array('id' => $row['id']))}" class="btn btn-default btn-sm"
                           title="{ifp 'groups.category.edit'}修改{else}查看{/if}"><i class="fa fa-edit"></i> {ifp 'groups.category.edit'}修改{else}查看{/if}</a>{/if}
                        {ifp 'groups.category.delete'}
                        <a data-toggle='ajaxRemove' href="{php echo webUrl('groups/category/delete', array('id' => $row['id']))}"class="btn btn-default btn-sm" data-confirm="确认删除此分类?" title="删除"><i class="fa fa-trash"></i> 删除</a>{/if}
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
        {$pager}
        {else}
        <div class='panel panel-default'>
            <div class='panel-body' style='text-align: center;padding:30px;'>
                暂时没有任何商品分类
            </div>
            {/if}
    </form>
{template '_footer'}